package com.alan.mvvm.base;

import androidx.annotation.NonNull;
import androidx.lifecycle.DefaultLifecycleObserver;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleEventObserver;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.ViewModel;

/**
 * ViewModel基础类 原则上所有的ViewModel都要继承BaseViewModel
 */
public class BaseViewModel extends ViewModel implements LifecycleEventObserver, DefaultLifecycleObserver {

    /**
     * Called when a state transition event happens.
     *
     * @param source The source of the event
     * @param event  The event
     */
    @Override
    public void onStateChanged(@NonNull LifecycleOwner source, @NonNull Lifecycle.Event event) {

    }


    public void onRestart() {

    }

    /**
     * 当是Fragment时,对应其onCreateView回调
     */
    public void onCreateView() {

    }
}
